package com.ruoyi.culture.service;

import com.ruoyi.culture.domain.ExhibitionInfo;
import com.ruoyi.culture.mapper.ExhibitionInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ExhibitionInfoService {

    @Autowired
    ExhibitionInfoMapper exhibitionInfoMapper;

    public void insert(ExhibitionInfo exhibitionInfo) {
        int insertResult = exhibitionInfoMapper.insert(exhibitionInfo);
        if (insertResult==0){
            throw new RuntimeException("新增展览资讯失败");
        }
    }

    public List<ExhibitionInfo> list() {
        List<ExhibitionInfo> list = exhibitionInfoMapper.list();
        return list;
    }

    public void update(ExhibitionInfo artistsInfo) {
        artistsInfo.setModifiedTime(new Date());
        int updateResult = exhibitionInfoMapper.update(artistsInfo);
        if (updateResult==0){
            throw new RuntimeException("修改展览资讯失败");
        }
    }

    public void delete(int id) {
        int deleteResult = exhibitionInfoMapper.delete(id);
        if (deleteResult==0){
            throw new RuntimeException("删除展览资讯失败");
        }
    }
}
